// Name:            Button
//
// Description:     Define style for buttons
//
// Component:       `.btn`
//
// Sub-objects:     `.btn-group`
//                  `.btn-dropdown`
//
// Modifiers:       `.btn-default`
//                  `.btn-primary`
//                  `.btn-warning`
//                  `.btn-success`
//                  `.btn-danger`
//                  `.btn-secondary`
//                  `.btn-link`
//                  `.btn-sm`
//                  `.btn-lg`
//                  `.btn-xs`
//                  `.btn-block`
//
// States:          `.active`
//                  `.disabled`
//
// =============================================================================


/* ==========================================================================
   Component: Button
 ============================================================================ */

// Button base styles
.btn {
  display: inline-block;
  margin-bottom: 0; // for input.am-btn
  padding: 0.5em 1em; // relative font size
  vertical-align: middle;
  font-size: $btn-font-size;
  font-weight: $btn-font-weight;
  line-height: $btn-line-height;
  text-align: center;
  white-space: nowrap;
  background-image: none;
  border: 1px solid transparent;
  border-radius: $global-radius;
  cursor: pointer;
  outline: 0;
  -webkit-appearance: none;
  user-select: none;
  transition: background-color 300ms ease-out, border-color 300ms ease-out;
  // @include hook-btn();

  &,
  &:active {
    &:focus {
      @include tab-focus;
    }
  }

  &:hover,
  &:focus {
    color: $btn-default-color;
    text-decoration: none;
    // @include hook-btn-hover();
  }

  &:active,
  &.active {
    background-image: none;
    box-shadow: inset 0 3px 5px rgba(0, 0, 0, .15);
    // @include hook-btn-active();
  }

  &.disabled,
  &[disabled],
  fieldset[disabled] & {
    // https://developer.mozilla.org/en-US/docs/Web/CSS/pointer-events
    pointer-events: none; // Disable mouse events
    border-color: transparent;
    cursor: not-allowed; // may not styled because pointer-events: none;
    opacity: 0.45;
    box-shadow: none;
    // @include hook-btn-disable();
  }

  &.round {
    border-radius: $global-rounded;
  }

  &.radius {
    border-radius: $radius-normal;
  }
}


// Modifiers
// =============================================================================

.btn-default {
  @include button-variant($btn-default-color, $btn-default-bg, $btn-default-border);
  // @include hook-btn-default();
}

.btn-primary {
  @include button-variant($btn-primary-color, $btn-primary-bg, $btn-primary-border);
  // @include hook-btn-primary();
}

.btn-warning {
  @include button-variant($btn-warning-color, $btn-warning-bg, $btn-warning-border);
  // @include hook-btn-warning();
}

.btn-danger {
  @include button-variant($btn-danger-color, $btn-danger-bg, $btn-danger-border);
  // @include hook-btn-danger();
}

.btn-success {
  @include button-variant($btn-success-color, $btn-success-bg, $btn-success-border);
  // @include hook-btn-success();
}

.btn-secondary {
  @include button-variant($btn-secondary-color, $btn-secondary-bg, $btn-secondary-border);
  // @include hook-btn-secondary();
}


/* Style links like a button */
.btn-link {
  color: $link-color;
  font-weight: normal;
  cursor: pointer;
  border-radius: 0;

  &,
  &:active,
  &[disabled],
  fieldset[disabled] & {
    background-color: transparent;
    box-shadow: none;
  }

  &,
  &:hover,
  &:focus,
  &:active {
    border-color: transparent;
  }

  &:hover,
  &:focus {
    color: $link-hover-color;
    text-decoration: underline;
    background-color: transparent;
  }

  &[disabled],
  fieldset[disabled] & {
    &:hover,
    &:focus {
      color: $btn-link-disabled-color;
      text-decoration: none;
    }
  }
}


/* button size */
.btn-xs {
  @include button-size($btn-xs-font-size);
  // @include hook-btn-xs();
}

.btn-sm {
  @include button-size($btn-sm-font-size);
  // @include hook-btn-sm();
}

.btn-lg {
  @include button-size($btn-lg-font-size);
  // @include hook-btn-lg();
}

.btn-xl {
  @include button-size($btn-xl-font-size);
  // @include hook-btn-xl();
}


/* Block button  */
.btn-block {
  display: block;
  width: 100%;
  padding-left: 0;
  padding-right: 0;
}


/* Multiple block buttons vertically space */
.btn-block + .btn-block {
  margin-top: 5px;
}


/* Specificity overrides */
input[type="submit"],
input[type="reset"],
input[type="button"] {
  &.btn-block {
    width: 100%;
  }
}


/* Button with loading spinner */
.btn.btn-loading {
  .icon-spin {
    margin-right: 5px;
  }
}


// Hooks
// =============================================================================

// @mixin hook-btn(){}
// @mixin hook-btn-hover(){}
// @mixin hook-btn-active(){}
// @mixin hook-btn-disable(){}

// @mixin hook-btn-default(){}
// @mixin hook-btn-primary(){}
// @mixin hook-btn-warning(){}
// @mixin hook-btn-danger(){}
// @mixin hook-btn-success(){}
// @mixin hook-btn-secondary(){}

// @mixin hook-btn-xs(){}
// @mixin hook-btn-sm(){}
// @mixin hook-btn-xl(){}
// @mixin hook-btn-lg(){}
